package common.fetch;

import common.entity.DetailListEntity;
import common.sql.Operator;

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author: Han
 * @date: 2018/9/13 15:37
 * @dscription: 四川领导人童泰
 */
public class Entrance {
    private Operator operator;

    private Entrance() {
        this.operator = Operator.getInstance();
    }

    public static void main(String... args) {

        Entrance entrance = new Entrance();
        entrance.start();
    }

    private void start() {
        List<DetailListEntity> detailListEntityList = operator.queryDetailList();
        ExecutorService executor = Executors.newFixedThreadPool(10);
        int threadCount = 0;
        for (DetailListEntity detailListEntity : detailListEntityList) {
            String source = detailListEntity.getSource();
            if ("四川省人民政府".equals(source)) {
                Pg pg = new Pg(detailListEntity);
                pg.setName("Thread-四川省人民政府" + threadCount);
                executor.submit(pg);
            } else if ("四川省发展和改革委员会".equals(source)) {
                Drc drc = new Drc(detailListEntity);
                drc.setName("Thread-四川省发展和改革委员会" + threadCount);
                executor.submit(drc);
            } else if ("四川省经济和信息化委员会".equals(source)) {
                Ceit ceit = new Ceit(detailListEntity);
                ceit.setName("Thread-四川省经济和信息化委员会" + threadCount);
                executor.submit(ceit);
            } else if ("四川省教育厅".equals(source)) {
                Ed ed = new Ed(detailListEntity);
                ed.setName("Thread-四川省教育厅" + threadCount);
                executor.submit(ed);
            } else if ("四川省民族宗教事务委员会".equals(source)) {
                Erac erac = new Erac(detailListEntity);
                erac.setName("Thread-四川省民族宗教事务委员会" + threadCount);
                executor.submit(erac);
            } else if ("四川省科技厅".equals(source)) {
                Std std = new Std(detailListEntity);
                std.setName("Thread-四川省科技厅" + threadCount);
                executor.submit(std);
            } else if ("四川省公安厅".equals(source)) {
                Psd psd = new Psd(detailListEntity);
                psd.setName("Thread-四川省公安厅" + threadCount);
                executor.submit(psd);
            } else if ("四川省民政厅".equals(source)) {
                Dca dca = new Dca(detailListEntity);
                dca.setName("Thread-四川省民政厅" + threadCount);
                executor.submit(dca);
            } else if ("四川省司法厅".equals(source)) {
                Dj dj = new Dj(detailListEntity);
                dj.setName("Thread-四川省司法厅" + threadCount);
                executor.submit(dj);
            } else if ("四川省人力资源和社会保障厅".equals(source)) {
                Hrssd hrssd = new Hrssd(detailListEntity);
                hrssd.setName("Thread-四川省人力资源和社会保障厅" + threadCount);
                executor.submit(hrssd);
            } else if ("四川省国土资源厅".equals(source)) {
                Lrd lrd = new Lrd(detailListEntity);
                lrd.setName("Thread-四川省国土资源厅" + threadCount);
                executor.submit(lrd);
            } else if ("四川省环境保护厅".equals(source)) {
                Epd epd = new Epd(detailListEntity);
                epd.setName("Thread-四川省环境保护厅" + threadCount);
                executor.submit(epd);
            } else if ("四川省交通运输厅".equals(source)) {
                Dt dt = new Dt(detailListEntity);
                dt.setName("Thread-四川省交通运输厅" + threadCount);
                executor.submit(dt);
            } else if ("四川省水利厅".equals(source)) {
                Wrd wrd = new Wrd(detailListEntity);
                wrd.setName("Thread-四川省水利厅" + threadCount);
                executor.submit(wrd);
            } else if ("四川省农业厅".equals(source)) {
                Ad ad = new Ad(detailListEntity);
                ad.setName("Thread-四川省农业厅" + threadCount);
                executor.submit(ad);
            } else if ("四川省商务厅".equals(source)) {
                Dc dc = new Dc(detailListEntity);
                dc.setName("Thread-四川省商务厅");
                executor.submit(dc);
            } else if ("四川省文化厅".equals(source)) {
                Doc doc = new Doc(detailListEntity);
                doc.setName("Thread-四川省文化厅");
                executor.submit(doc);
            } else if ("四川省卫生和计划生育委员会".equals(source)) {
                Hfpc hfpc = new Hfpc(detailListEntity);
                hfpc.setName("Thread-四川省卫生和计划生育委员会-" + threadCount);
                executor.submit(hfpc);
            } else if ("四川省审计厅".equals(source)) {
                Spad spad = new Spad(detailListEntity);
                spad.setName("Thread-四川省审计厅-" + threadCount);
                executor.submit(spad);
            } else if ("四川省人民政府外事侨务办公室".equals(source)) {
                Foca foca = new Foca(detailListEntity);
                foca.setName("Thread-四川省人民政府外事侨务办公室-" + threadCount);
                executor.submit(foca);
            } else if ("四川省旅游发展委员会".equals(source)) {
                Td td = new Td(detailListEntity);
                td.setName("Thread-四川省旅游发展委员会-" + threadCount);
                executor.submit(td);
            } else if ("四川省政府国有资产监督管理委员会".equals(source)) {
                Soasac soasac = new Soasac(detailListEntity);
                soasac.setName("Thread-四川省政府国有资产监督管理委员会-" + threadCount);
                executor.submit(soasac);
            } else if ("四川省质量技术监督局".equals(source)) {
                Aqts aqts = new Aqts(detailListEntity);
                aqts.setName("Thread-四川省质量技术监督局-" + threadCount);
                executor.submit(aqts);
            } else if ("四川省食品药品监督管理局".equals(source)) {
                Fda fda = new Fda(detailListEntity);
                fda.setName("Thread-四川省食品药品监督管理局-" + threadCount);
                executor.submit(fda);
            } else if ("四川省安全生产监督管理局&四川煤矿安全监察局".equals(source)) {
                Aqjgjc aqjgjc = new Aqjgjc(detailListEntity);
                aqjgjc.setName("Thread-四川省安全生产监督管理局&四川煤矿安全监察局-" + threadCount);
                executor.submit(aqjgjc);
            } else if ("四川省博览局".equals(source)) {
                Bea bea = new Bea(detailListEntity);
                bea.setName("Thread-四川省博览局-" + threadCount);
                executor.submit(bea);
            }
            threadCount++;
        }
        executor.shutdown();
    }
}
